﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Characters.Mobs.Bosses.Endgame_1;
using The_Chronicles_of_Asku.Areas.End_Game_Floors.Tower._1_5.Resources;
using The_Chronicles_of_Asku.Characters;
using The_Chronicles_of_Asku.Characters.Mobs;

namespace The_Chronicles_of_Asku.Areas.End_Game_Floors.Tower._1_5
{
    class TowerFloorOne
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();
        Bandit bandit = new Bandit();
        public bool complete = false;

        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelFiftyTierFourteen(skel, necro, zombie, bandit);

            Console.WriteLine(FloorOneText.Entrance, myHero.Identifier);
            ClearScreen();
            Console.WriteLine(FloorOneText.FirstThing);
            ClearScreen();

            Console.WriteLine(FloorOneText.SecondThing);
            SkeletonFight(myHero, skel);
            UndeadFight(myHero, zombie);
            SkeletonFight(myHero, skel);
            UndeadFight(myHero, zombie);
            SkeletonFight(myHero, skel);
            UndeadFight(myHero, zombie);
            SkeletonFight(myHero, skel);
            UndeadFight(myHero, zombie);
            SkeletonFight(myHero, skel);

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorOneText.ThirdThing);
                NecromancerFight(myHero, necro);
                NecromancerFight(myHero, necro);
                NecromancerFight(myHero, necro);
                NecromancerFight(myHero, necro);
                NecromancerFight(myHero, necro);
            }

            if (myHero.isAlive == true)
            {
                string answer = "";

                do
                {
                    Console.WriteLine(FloorOneText.FourthThingOne);
                    answer = Console.ReadLine();

                    switch (answer)
                    {
                        case "1":
                            if (myHero.isAlive)
                            {
                                Console.WriteLine(FloorOneText.FourthThingLeftOne);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                SkeletonFight(myHero, skel);
                                if (myHero.isAlive == true)
                                {
                                    Console.WriteLine(FloorOneText.FourthThingLeftTwo);
                                    ClearScreen();
                                }
                                else
                                    answer = "2";

                            }
                            else
                                answer = "2";
                            break;

                        case "2":
                            if (myHero.isAlive)
                            {
                                Console.WriteLine(FloorOneText.FourthThingRight);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                                UndeadFight(myHero, zombie);
                            }
                            else
                                answer = "2";
                            break;

                        default:
                            Console.WriteLine("Invalid choice!");
                            ClearScreen();
                            break;
                    }
                } while (answer != "2" && myHero.isAlive);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorOneText.FifthThing);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorOneText.Exit);
                ClearScreen();
                complete = true;
            }


            if (myHero.isAlive == false)
            {
                Console.WriteLine(FloorOneText.Dead);
                myHero.isAlive = true;
            }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }

        private void BanditFight(Hero myHero, Bandit bandit)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, bandit);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            bandit.ResetStats(bandit);

            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
